 var record = window.parent.artclepanel.getSelectionModel().getSelection();
 var temarticleID = record[0].get("articleID"); //这里为Grid数据源的Id列    
 var temtitle = record[0].get("title"); //这里为Grid数据源的Id列
//alert(temarticleID);
//alert(temtitle);

getOneDisplay = function(value, record) {

	var rowIndex = OneCombo.store.find("id", value);
	alert(rowIndex);
	if (rowIndex < 0)
		return '';
	var record = OneCombo.store.getAt(rowIndex);
	//alert(record.get("text"));
	return record ? record.get('text') : '';
};
Ext.onReady(function() {
	
	//var sexNode = artcleform.findField('channelid').getStore().findRecord('sexId', sexValue);//在性别下拉框对应的store中查找与原值相等的记录，就是sexValu为1，则在store中查找value对于1的记录，也就是<option value=1></option>。  
     //artcleform.findField('channelid').select(2);//下拉框中选中该记录，也就选中该<option></option> 
	
	Ext.Ajax.request({
									url : '/test/articles/detailarticle.do',
									params : {
										title : temtitle,
										articleID : temarticleID
									},
									method : 'POST',
									success : function(response, options) {
										//artcleform.getForm().loadRecord(response);
										var result = Ext
												.decode(response.responseText);
										if (result.success) {
											var redode = result.data;
											var content = result.content;
											var publishdate2 = result.publishdate2;
											//alert(publishdate2);
											 uploaddata(redode,content,publishdate2);
											//alert(redode);
											//artclepanel.store.remove(record);//参数是record类型的,移除该数据

											//Ext.Msg.alert('提示', '删除文章信息成功!');

										} 
									},
									failure : function(response, options) {

										Ext.Msg.alert('提示', '读取文章信息请求失败!');
									}

								});
//var cont = KindEditor.html(); // 获取编辑区域内容

       
 			var editor1 = KindEditor.create('textarea[name="content1"]', {
				cssPath : '../plugins/code/prettify.css',
				uploadJson : '../jsp/upload_json.jsp',
				fileManagerJson : '../jsp/file_manager_json.jsp',
				allowFileManager : true,
				afterCreate : function() {
					var self = this;
					KindEditor.ctrl(document, 13, function() {
						self.sync();
						document.forms['example'].submit();
					});
					KindEditor.ctrl(self.edit.doc, 13, function() {
						self.sync();
						document.forms['example'].submit();
					});
				}
			});
		
       
   var channelstore = Ext.create("Ext.data.Store", {
   fields : ['channelid', 'channelname'],
    autoLoad: true,
   data : [
   	{channelname: "军事", channelid: 1},
    {channelname: "财经", channelid: 2},
    {channelname: "社会", channelid: 3},
    {channelname: "历史", channelid: 4},
    {channelname: "文化", channelid: 5}
   ]
});          
           
	var artcleform = Ext.create('Ext.form.Panel', {

				width : 670,
				height:670,
				bodyPadding : 10,
				frame : true,
				renderTo : Ext.getBody(),
				items : [{
							xtype : 'numberfield',
							fieldLabel : '内容ID',
							name : 'contentid',
							id : 'contentid',
							allowBlank : true,
							hideLabel:true,
							hidden:true,
							anchor : '60%'
						},{
							xtype : 'textfield',
							fieldLabel : '文章ID',
							name : 'articleID',
							id : 'articleID',
							allowBlank : true,
							hideLabel:true,
							hidden:true,
							anchor : '60%'
						},{
							xtype : 'textfield',
							fieldLabel : '文章标题',
							name : 'title',
							id : 'title',
							allowBlank : true,
							emptyText : '请输入文章标题',
							anchor : '60%'
						}, {
							xtype : 'textfield',
							fieldLabel : "作者",
							id : 'author',
							name : 'author',
							anchor : '60%',
							step : 50,
							allowBlank : true,
							emptyText : '请填入作者'

						},

						{
							xtype : 'textfield',
							fieldLabel : '来源',
							name : 'source',
							id : 'source',
							allowBlank : true,
							anchor : '40%',

							emptyText : '请输入来源'
						}, {
							xtype : 'datefield',
							fieldLabel : '发布日期',
							name : 'publishdate2',
							format : 'Y-m-d',
							maxValue : new Date(),
							id : 'publishdate2',
							allowBlank : true,
							

							emptyText : '请输入发布日期'
						},
						{
                         fieldLabel : "文章类型",//显示的Label
                         xtype : "combo",//使用xtype定义
                         hiddenName :"channelid",
                         id:"channelid",
                         name : "channelid",//提交到后台的id//form提交时的名称
                         valueField:"channelid",//俗称的key
                         displayField:"channelname",//俗称前台显示的value
                         store:channelstore,//数据源//绑定的Store
                         emptyText:'---请选择---',//当没有值时的水印文字
                         //renderer : getOneDisplay,
                         editable: false,
                          allowBlank : false
                     },
						//{
   // xtype: 'extkindeditor',
   // allowBlank: false,
   // name: 'Responsibilities',
  //  height: 140,
   //     width:670,
   // id: 'Responsibilities',
   // fieldLabel: '岗位职责'
//} ,

						//HtmlEditor,
						//Nceditor.html(cont); //给编辑区域加载内容

//Nceditor.edit.setHeight('200px'); // 动态修改编辑区域高度


						 {
             xtype:'textareafield',
            
             region:'center',
             name: 'content',
             id: 'content',
             width:'auto',  
             height:'auto',
             listeners: {
                 'render': function (f) {
                     
                         if (KindEditor) {
                             Nceditor = KindEditor.create('#content-bodyEl textarea[name="content"]', {
                                // cssPath: '../js/kindeditor/plugins/code/prettify.css',
                                 resizeType: 1,
                                 resizeMode: 0,
                                 allowFileManager: true,
                                  afterCreate : function() {
         this.sync();
        },
        //失去焦点同步数据到textarea
        afterBlur:function(){
            this.sync();
        } 
        
                             });
                         }
                     
                 }
             }
         }

				],

				buttons : [{
							text : '上传',
							handler : function() {
								var form = this.up('form').getForm();
								if (form.isValid()) {
									var formValues=this.up('form').getForm().getValues(); //获取表单中的所有Name键/值对对象
                                    //alert(formValues["firstname"]); //输出表单中 firstname 字段的值
									// alert('表单的值:'+
									// this.up('form').getForm().getValue());
									form.submit({
												method : "POST",
												url : '/test/articles/savearticle.do',
												waitMsg : '修改文章...',
												//parms:{"cont":cont},
												success : function(fp, o) {
												Ext.Msg.alert("上传成功！");
												},
												failure : function(fp, o) {
													Ext.Msg.alert("上传失败！");
												}
											});
								}
							}
						}]
			});
		function uploaddata(redode,content,publishdate2) {
	//redode.toString();
	//alert(publishdate2);
	artcleform.getForm().setValues(redode[0]);
	//artcleform.down("combobox[name=channelid]").setValue(1);
	//KindEditor.html("#content",redode[0].get("content")); 
	Ext.getCmp('publishdate2').setValue(publishdate2);
	//Ext.getCmp('channelid').setRawValue(3);
	//alert(content);
	Nceditor.html(content,"content");
}	
			
});
